//
//  Dictionary-Extension.swift
//  HoneyBee
//
//  Created by point on 2018/2/25.
//  Copyright © 2018年 point. All rights reserved.
//

import UIKit

extension Dictionary {
    func formatApi() -> String {
        var str = ""
        for (key,value) in self {
            str = str+("&\(key)=\(value)")
        }
        let startIndex = str.index(str.startIndex, offsetBy: 0)
        let endIndex = str.index(str.startIndex, offsetBy: 0)
        str = str.replacingCharacters(in: startIndex...endIndex, with: "?")
        //参数 里面 汉字转一下
        guard let result = str.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) else {
            print("参数异常")
            return ""
        }
        return result
    }
}
